import { Transform } from '@antv/x6-plugin-transform'
import { Snapline } from '@antv/x6-plugin-snapline'
import { Clipboard } from '@antv/x6-plugin-clipboard'
import { Selection } from '@antv/x6-plugin-selection'
import { Keyboard } from '@antv/x6-plugin-keyboard'
import { History } from '@antv/x6-plugin-history'
import { Scroller } from '@antv/x6-plugin-scroller'
import { defineStore } from 'pinia'
import {Options as X6OP} from '@antv/x6'

interface X6State{
  graphConfig:Partial<X6OP.Manual>,
  transformConfig:Transform.Options,
  snapLineConfig:Snapline.Options,
  clipboardConfig:Clipboard.Options,
  selectConfig:Selection.Options,
  //@ts-ignore
  keyboardConfig:Keyboard.Options,
  historyConfig:History.Options,
  scrollerConfig:Scroller.Options,
}
export const useX6Store=defineStore('x6',{
  state: ():X6State => {
    return {
      graphConfig:{

      },
      transformConfig:{
        resizing:{
          enabled: false,
          minWidth: 1,
          minHeight: 1,
          orthogonal: true,
          restrict: false,
          preserveAspectRatio: false,
        },
        rotating:{
          enabled: false,
          grid: 1,
        }
      },
      snapLineConfig:{
        enabled: true,
        clean: false,
        resizing:true,
        tolerance:10,
      },
      clipboardConfig:{
        enabled: true,
        useLocalStorage: true,
      },
      selectConfig:{
        enabled: true,
        multiple: true,
        rubberband: true,
        movable: true,
        showEdgeSelectionBox:false,
        showNodeSelectionBox: false,
        strict: true,
        modifiers: ['alt',"ctrl",'meta'],
        content: false,
      },
      keyboardConfig:{
        enabled: true,
        global: true,
      },
      historyConfig:{
        enabled:true,
      },
      scrollerConfig:{
        enabled: true,
        pageVisible: true,
        pageBreak: true,
        pannable: true,
        autoResize: true,
        minVisibleWidth: 50,
        minVisibleHeight: 50,
      },
    }
  },
  //持久化
  persist:true
})
